package com.alu4r.atcrowdfunding.manager.service.impl;

import com.alu4r.atcrowdfunding.VO.Data;
import com.alu4r.atcrowdfunding.bean.Role;
import com.alu4r.atcrowdfunding.manager.dao.RoleMapper;
import com.alu4r.atcrowdfunding.manager.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    RoleMapper roleMapper;

    @Override
    public List<Role> queryAllRole() {
        return roleMapper.selectAll();
    }

    @Override
    public boolean saveAssignPermission(Integer roleId, Data data) {
        try {
            roleMapper.deleteByroleId(roleId);
            roleMapper.saveAssignPermission(roleId,data);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
}
